package com.hhsj.ui.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;

//均分布局，设置布局的占比
public class EquallyLayoutV2 extends LinearLayout {

    public EquallyLayoutV2(Context context) {
        super(context);
    }

    public EquallyLayoutV2(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public EquallyLayoutV2(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public void onViewAdded(View child) {
        super.onViewAdded(child);
        LayoutParams params = (LayoutParams) child.getLayoutParams();
        if (getOrientation() == LinearLayout.VERTICAL) {
            params.height = 0;
        } else {
            params.width = 0;
        }
        params.weight = 1;
    }
}
